/**
 * 用来将虚拟dom创建为真实dom的操作
 * @param {Object} vnode
 * @returns
 */
export default function myCreateElement(vnode) {
  console.log(vnode, 'myCreateElement(vnode)')
  let domNode = document.createElement(vnode.sel)
  if (
    vnode.text != '' &&
    (vnode.children == undefined || vnode.children.length == 0)
  ) {
    domNode.innerText = vnode.text
  } else if (Array.isArray(vnode.children) && vnode.children.length > 0) {
    for (let i = 0; i < vnode.children.length; i++) {
      let ch = vnode.children[i]
      let chDom = myCreateElement(ch)
      domNode.appendChild(chDom)
    }
  }
  vnode.elm = domNode
  return vnode.elm
}
